from datetime import timedelta, datetime

# 在现在的时间基础上，往后两天 的时间
t1 = timedelta(days=2, hours=2)
print(t1) # 2 days, 2:00:00

# 得到当前时间的后两天.
t2 = datetime.now() + timedelta(days=2)
print(t2) # 2025-09-24 09:02:59.281501

# 相减
ini_time_str = '2020/8/3 23:00:51'
end_time_str = '2020/9/1 7:48:50'

start = datetime.strptime(ini_time_str, '%Y/%m/%d %H:%M:%S')
end = datetime.strptime(end_time_str, '%Y/%m/%d %H:%M:%S')
t3 = end - start
print(t3)  # 28 days, 8:47:59
print(type(t3))  # <class 'datetime.timedelta'>
print(t3.days, t3.seconds, t3.microseconds)  # 28 31679 0
